home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / ACORNUSERS / EMULATOR / ASM6502 / examples / c64snow < prev    next >
Text File  |  1998-08-26  |  3KB  |  87 lines

  1. ;Screen Scrambler
  2. ;Illustrates the technique of using pixel data to manipulate the screen
  3. ;and leaving the color information stationary for a wierd effect.
  4. ;It does also illustrate the usage of the random number generator and
  5. ;the speed impact that self-modifying code gives.
  6. ;By Todd S. Elliott
  7.  
  8. ;Updated for asm6502 by Alain BROBECKER, on 04-Aug-1998.
  9. ;Works fine with Frodo v4.1 but not with BreadBox64.
  10.             #name       c64snowX
  11.             #type       &064
  12.             #list
  13.             #base       &801-2
  14.  
  15. #set vicontrol = 53272  ;vic control register
  16. #set scrmem = 1024      ;location of screen memory
  17. #set vic = 53248        ;vic ii chip register
  18. #set multiclr = 53270   ;multi-color register
  19. #set charbase = 14336   ;char base address
  20. #set backgnd = 53281    ;background color register
  21. #set multi1 = 53282     ;multi-color register one
  22. #set multi2 = 53283     ;multi-color register two
  23. #set frehi3 = 54287     ;frequency register three
  24. #set vcreg3 = 54290     ;voice control register three
  25. #set sigvol = 54296     ;oscillator three
  26. #set random = 54299     ;random generator
  27.  
  28. ;---- C64 specific part... loading adress+BASIC stuff --------------------------
  29.   #rw       &0801                   ;Load adress (C64)
  30.   #rw       BasicEnd,1997           ;Adress of next line + line number
  31.   #b        &9e,&32,&30,&36,&32     ;Basic "SYS 2062" instruction
  32.   #b        0                       ;End of basic line
  33. .BasicEnd
  34.   #b        0,0,0                   ;End of basic program
  35. ;---- Assembly language ForEVER ------------------------------------------------
  36. .start
  37.  
  38. ;initializes the screen
  39.   lda #151              ;char code for color dark gray
  40.   jsr &ffd2             ;changes video color matrix color to dark gray
  41.   lda #147:jsr &ffd2    ;clears the screen
  42.   lda #&ff              ;set voice three to max.
  43.   sta frehi3
  44.   lda #128
  45.   sta vcreg3
  46.   sta sigvol            ;turn on random generator for random numbers
  47.   ldy #&00              ;load offset
  48. .back0:tya              ;transfer to accumulator
  49.   sta scrmem,y          ;store char code
  50.   sta scrmem+256,y
  51.   sta scrmem+512,y
  52.   sta scrmem+768,y
  53.   dey                   ;decrement offset
  54.   bne back0             ;if not equal, branch back
  55.   lda vicontrol         ;get the values of the vic control register
  56.   and #240              ;protect bits
  57.   ora #14               ;store offset
  58.   sta vicontrol         ;change the modified value to point to 14336
  59.   lda multiclr          ;get the bit values of the multi color register
  60.   ora #16               ;turn on bit 4
  61.   sta multiclr          ;switch on multi color
  62.   lda #&00              ;color black
  63.   sta 53280             ;border register
  64.  
  65. ;starts the whole shebang!
  66. ;This uses self-modifying code for the sake of speed and efficiency.
  67.   lda #&01
  68.   sta multi1
  69.   lda #&00
  70.   sta backgnd
  71.   lda #&0f
  72.   sta multi2
  73. .back1:lda #charbase AND &ff ;low byte
  74.   ldy #charbase>>8      ;high byte
  75.   sta base+1
  76.   sty base+2
  77.   ldx #&07              ;x-offset
  78. .back2:ldy #&00         ;y-offset
  79. .back3:lda random       ;get a random number
  80. .base:sta &ffff,y       ;and store it into mem.
  81.   dey
  82.   bne back3             ;decrement 256 counter and loop back
  83.   inc base+2            ;decrement high byte of character base
  84.   dex
  85.   bpl back2             ;decrements the page counter and branches back
  86.   jmp back1             ;ad infinitum...
  87.